﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using System.IO;

// NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "ITransferFiles" in both code and config file together.
[ServiceContract()]
public interface ITransferFiles
{
    [OperationContract]
    RemoteFileInfo DownloadFile(DownloadRequest request);

    [OperationContract]
    void UploadFile(RemoteFileInfo request);

    


    [OperationContract]
    int AuthUser(string username, string pwd);


    [OperationContract]
    List<FileInformation> GetList(string username, string pwd, int group);

    [OperationContract]
    List<HelperClass> GetGroups();

    [OperationContract]
    int ChangePassword(string username, string pwd, string updateUser, string newPwd);

    [OperationContract]
    List<HelperClass> GetUsers(string username, string pwd, string groupName);

    [OperationContract]
    int DeleteUser(string username, string pwd, string delUserName);

    [OperationContract]
    int AddUser(HelperClass user, HelperClass newUser);

    [OperationContract]
    int AddGroup(string username, string pwd, string groupName);

    [OperationContract]
    int DelGroup(string username, string pwd, string groupName);

    [OperationContract]
    int DeleteFile(string username, string pwd, string filepath);

}

[MessageContract]
public class DownloadRequest
{
    [MessageHeader(MustUnderstand = true)]
    public string UserName { get; set; }

    [MessageHeader(MustUnderstand = true)]
    public string Password { get; set; }

    [MessageHeader(MustUnderstand = true)]
    public string FileName { get; set; }    

    [MessageHeader(MustUnderstand = true)]
    public string FilePart { get; set; }
    
}

[MessageContract]
public class RemoteFileInfo 
{
    
    [MessageHeader(MustUnderstand = true)]
    public string UserName {get; set;}

    [MessageHeader(MustUnderstand = true)]
    public string Password { get; set; }

    [MessageHeader(MustUnderstand = true)]
    public string Group { get; set; }

    [MessageHeader(MustUnderstand = true)]
    public string FileName { get; set; }

    [MessageHeader(MustUnderstand = true)]
    public int FileStart { get; set; }

    [MessageHeader(MustUnderstand = true)]
    public long FileSize { get; set; }

    [MessageHeader(MustUnderstand = true)]
    public int NumParts { get; set; }


    
    

    [MessageBodyMember(Order = 1)]
    public Stream FileByteStream;

   /* public void Dispoase()
    {
        if (FileByteStream != null)
        {
            FileByteStream.Close();
            FileByteStream = null;
        }
    }


    void IDisposable.Dispose()
    {
        FileByteStream.Dispose();
    }*/
    
                
           
}




